from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from time import sleep


import sys

sys.path.append(r'..')
from web_base.base_page import BasePage
from page_object.login_page import LoginPage

class AssetPage(BasePage):
    url = r'/bsams/front/asset/asset_list.do'
    #借用定位
    add_ben_loc = (By.XPATH, '//*[@id="leftmenu_asset_user"]/div[1]/a/img')
    mod_phone_loc = (By.ID, 'phone')
    mod_ok_loc = (By.CLASS_NAME, 'button_fujian')
    def change_phone(self,phone):
        self.open()
        self.ele_click(self.add_ben_loc)
        sleep(2)
        self.ele_clear(self.mod_phone_loc)
        self.input_ele(self.mod_phone_loc,phone)
        sleep(1)
        self.ele_click(self.mod_ok_loc)
        sleep(3)

if __name__ == '__main__':
    phone='15936536978'

    chrome_location = r'D:\测试工具\Win_x64_1135105_chrome-win\chrome-win\chrome.exe'
    options = webdriver.ChromeOptions()
    options.binary_location = chrome_location
    driver_location = r'D:\测试工具\pythan\chromedriver.exe'
    service = Service(driver_location)

    driver=webdriver.Chrome(options=options,service=service)

    login_page = LoginPage(driver)
    login_page.login()

    asset_page = AssetPage(driver)
    asset_page.change_phone(phone)
    driver.quit()